//package com.lx.demo.sync.jobhandler;
//
//import cn.hutool.core.util.RandomUtil;
//import com.lx.demo.mapper.UserMobilePlanMapper;
//import com.lx.demo.vo.UserMobilePlan;
//import com.xxl.job.core.context.XxlJobHelper;
//import com.xxl.job.core.handler.annotation.XxlJob;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import java.util.Date;
//import java.util.List;
//import java.util.concurrent.TimeUnit;
//
///**
// * @author wcy
// */
//@Component
//public class JocConfig {
//
//    @Resource
//    UserMobilePlanMapper userMobilePlanMapper;
//
//    @XxlJob("sendMsgShardingHandler")
//    public void sendMsgShardingHandler()  {
//        System.out.println("任务开始时间:"+new Date());
//        int shardTotal = XxlJobHelper.getShardTotal();
//        int shardIndex = XxlJobHelper.getShardIndex();
//        List<UserMobilePlan> userMobilePlans = null;
//        if(shardTotal==1){
//            //如果没有分片就直接查询所有数据
//            userMobilePlans = userMobilePlanMapper.selectAll();
//        }else{
//            userMobilePlans = userMobilePlanMapper.selectByMod(shardIndex,shardTotal);
//        }
//        System.out.println("处理任务数量:"+userMobilePlans.size());
//        Long startTime = System.currentTimeMillis();
//        userMobilePlans.forEach(item->{
//            try {
//                TimeUnit.MILLISECONDS.sleep(10);
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
//        });
//        System.out.println("任务结束时间:"+new Date());
//        System.out.println("任务耗时:"+(System.currentTimeMillis()-startTime)+"毫秒");
//    }
//}
